/**
  * Created by wyc on 6/11/2017.
  */
package ninenineqs

object p05 {
  def reverse_v1[T](input:List[T]):List[T] = {
    input.reverse
  }
  def reverse_v2[T](input:List[T]):List[T] = {
    input match {
      case Nil => Nil
      case h :: tail => reverse_v2(tail) ++ List[T](h)
    }
  }
  def reverse_v3[T](input:List[T]):List[T] = {
    input.foldLeft(List[T]()) {(h, x) => x :: h}
  }
}
